package com.chenyitun.cloudsystem.base;

import com.chenyitun.cloudcommon.base.BaseEntity;
import com.chenyitun.cloudcommon.utils.StringUtils;
import com.chenyitun.cloudsystem.utils.ShiroUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class BaseService {
    protected Logger LOGGER = LoggerFactory.getLogger(getClass());

    protected BaseEntity fillMarks(BaseEntity clazz ){
        Long userId = 1l ;
        if(ShiroUtils.getUser() != null && ShiroUtils.getUser().getUserId() != null)
            userId = ShiroUtils.getUser().getUserId();
        clazz.setUpdateBy(userId);
        clazz.setUpdateTime(new Date());
        if(clazz.getId() == null){
            clazz.setCreateBy(userId);
            clazz.setCreateTime(new Date());
            if(StringUtils.isBlank(clazz.getStatus()))
                clazz.setStatus(BaseEntity.STATUS_NORMAL);
        }
        return clazz;
    }


}
